<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/all.conf.php');
require_once(__PHY_LIB.'/class/FnOrder.class.php');

$rPayment = array(
	'account' => 'tygoonray@hotmail.com',
	'currency' => 'USD',
);
$oOrder = new Order($_REQUEST['order']);
$rOrder = $oOrder->getData();
$rOrder['title'] = 'Order No('.$rOrder['id'].') from TheVisus.com';
$rOrder['PriceUSD'] = ('dollor' == $rOrder['payment_money'] ? ceil($rOrder['total_price']) : ceil($rOrder['total_price']/6.5));

$sHtml = '<html><head>'."\n"
	. '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n"
	. '</head>'."\n"
	. '<body onLoad="javascript:document.fm.submit()">'."\n"
	. '<form name="fm" action="https://www.paypal.com/cgi-bin/webscr" method="post">'."\n" // 不能省略
	. '<input type="hidden" name="cmd" value="_xclick" />'."\n" // 不能省略
	. '<input type="hidden" name="business" value="'.htmlspecialchars($rPayment['account']).'" />'."\n"             // 贝宝帐号
	. '<input type="hidden" name="return" value="'.htmlspecialchars(__HST.'/api/paypal/paid.php').'" />'."\n"       // 付款后页面
	. '<input type="hidden" name="amount" value="'.htmlspecialchars($rOrder['PriceUSD']).'" />'."\n"                // 订单金额
	. '<input type="hidden" name="invoice" value="'.htmlspecialchars($rOrder['id']).'" />'."\n"                     // 订单号
	. '<input type="hidden" name="charset" value="utf-8" />'."\n"                                                   // 字符集
	. '<input type="hidden" name="no_shipping" value="1" />'."\n"                                                   // 不要求客户提供收货地址
	. '<input type="hidden" name="no_note" value="" />'."\n"                                                        // 付款说明
	. '<input type="hidden" name="currency_code" value="'.htmlspecialchars($rPayment['currency']).'" />'."\n"       // 货币
	. '<input type="hidden" name="notify_url" value="'.htmlspecialchars(__HST.'/api/paypal/paid.php').'" />'."\n"   // 异步通知页面 
	. '<input type="hidden" name="item_name" value="'.htmlspecialchars($rOrder['title']).'" />'."\n"                // 名称
	. '</form></body>';
echo $sHtml;
?>
